package serviceimpl;

import java.io.Serializable;

import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;

import dao.GenericDao;
import domain.BaseEntity;

import service.CommonStudentManager;
@Transactional
public class CommonStudentManagerimpl<T extends BaseEntity<PK>, PK extends Serializable> implements CommonStudentManager<T, PK> {
	protected GenericDao<T, PK> dao;

	public void delete(PK id) {
		this.dao.deleteById(id);
	}

	public Iterable<T> findAll() {
		return this.dao.findAll();
	}

	public Page<T> findAll(Pageable page) {
		Page<T> result = this.dao.findAll(page);
		return result;
	}

	public T findById(PK id) {
		return this.dao.findById(id).get();
	}

	public Iterable<T> save(Iterable<T> entities) {
		return this.dao.saveAll(entities);
	}

	public T save(T entity) {
		T data = this.dao.save(entity);
		return data;
	}

	public void deleteAll() {
		this.dao.deleteAll();
	}

	public long count() {
		return this.dao.count();
	}

	}
